﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.events.*;
    import Engine.Events.*;
    import Engine.Managers.*;
    import Engine.Helpers.*;
    import Mechanics.GameMechanicInterfaces.*;
    import Mechanics.*;
    import flash.utils.*;
    import Classes.util.*;
    import Classes.sim.*;
    import __AS3__.vec.*;
    import ZLocalization.*;
    import validation.*;
    import Classes.bonus.*;
    import Engine.*;
    import Mechanics.GameEventMechanics.*;

    public class Item extends GameSettingsObject {

        public static const UNLOCK_LOCKED:String = "locked";
        public static const UNLOCK_LEVEL:String = "level";
        public static const UNLOCK_NEIGHBOR:String = "neighbor";
        public static const UNLOCK_PERMITS:String = "permits";
        public static const UNLOCK_QUEST_FLAG:String = "questflag";
        public static const UNLOCK_SEEN_FLAG:String = "seenflag";
        public static const UNLOCK_POPULATION:String = "population";
        public static const UNLOCK_QUEST_AND_LEVEL:String = "quest_and_level";
        public static const UNLOCK_QUEST_AND_NEIGHBOR:String = "quest_and_neighbor";
        public static const UNLOCK_OLD_QUEST_OR_PURCHASE:String = "old_quest_or_purchase";
        public static const COST_COINS:String = "coins";
        public static const COST_CASH:String = "cash";
        public static const COST_BOTH:String = "both";
        public static const PERMIT_ITEM:String = "permits";
        public static const HOLIDAY2010_TREE_ITEM:String = "holiday_tree_2010";
        public static const HOLIDAY2010_PRESENT_ITEM:String = "present_holiday_2010";
        public static const DIRECTION_SW:int = 0;
        public static const DIRECTION_SE:int = 1;
        public static const DIRECTION_NE:int = 2;
        public static const DIRECTION_NW:int = 3;
        public static const DIRECTION_MAX:int = 4;
        public static const DIRECTION_N:int = 4;
        public static const DIRECTION_E:int = 5;
        public static const DIRECTION_S:int = 6;
        public static const DIRECTION_W:int = 7;
        public static const DIRECTION_8_MAX:int = 8;
        public static const DIRECTION_SWW:int = 8;
        public static const DIRECTION_NWW:int = 9;
        public static const DIRECTION_NNW:int = 10;
        public static const DIRECTION_NNE:int = 11;
        public static const DIRECTION_NEE:int = 12;
        public static const DIRECTION_SEE:int = 13;
        public static const DIRECTION_SSE:int = 14;
        public static const DIRECTION_SSW:int = 15;
        public static const DIRECTION_16_MAX:int = 16;
        public static const DEFAULT_DIRECTION:int = 0;
        public static const DEFAULT_PHASE:String = null;
        protected static const UNKNOWN_ITEM_NAME:String = "## unknown item name ##";

        protected static var m_loadedAssets:Array = [];

        protected var m_cachedImages:Array;
        protected var m_collisionData:Array;
        protected var m_set:Set;
        protected var m_bonuses:Array;
        protected var m_tickers:Dictionary = null;
        protected var m_acceptBonus:Boolean = true;
        protected var m_toasters:Dictionary = null;
        protected var m_validations:Dictionary;
        protected var m_localizedName:String;
        protected var m_code:String;
        protected var m_noAutoScale:Number;
        protected var m_noAutoRotate:Boolean;
        protected var m_imageScale:Number;
        protected var m_buyable:Boolean;
        protected var m_experiments:Dictionary;
        protected var m_noMarket:Boolean;
        protected var m_placeable:Boolean;
        protected var m_requestOnly:Boolean;
        protected var m_special_onclick:String;
        protected var m_persistent:Boolean;
        protected var m_consumable:Boolean;
        protected var m_giftable:Boolean;
        protected var m_newTabPriority:Boolean;
        protected var m_sellSendsToInventory:Boolean;
        protected var m_sale:int;
        protected var m_cost:int;
        protected var m_cash:int;
        protected var m_goods:int;
        protected var m_fbc:int;
        protected var m_level:int;
        protected var m_requiredLevel:int;
        protected var m_dailyCollect:int;
        protected var m_type:String;
        protected var m_subtype:String;
        protected var m_behavior:String;
        protected var m_category:String;
        protected var m_className:String;
        protected var m_unlock:String;
        protected var m_unlockCost:int;
        protected var m_unlockShareFunc:String;
        protected var m_requiredPopulation:int;
        protected var m_requiredNeighbors:int;
        protected var m_requiredQuestFlag:String;
        protected var m_requiredSeenFlag:String;
        protected var m_count:int;
        protected var m_coinYield:int;
        protected var m_xpYield:int;
        protected var m_market:String;
        protected var m_multiplace:Boolean;
        protected var m_multiplant:Boolean;
        protected var m_useTileHighlight:Boolean;
        protected var m_useTilePicking:Boolean;
        protected var m_construction:String;
        protected var m_truckNum:int;
        protected var m_harvestEnergyCost:int;
        protected var m_buildEnergyCost:int;
        protected var m_cleanEnergyCost:int;
        protected var m_plantEnergyCost:int;
        protected var m_clearEnergyCost:int;
        protected var m_unlockMovementEnergyCost:int;
        protected var m_openEnergyCost:int;
        protected var m_instantFinishEnergyCost:int;
        protected var m_clearXpReward:int;
        protected var m_clearGoldReward:int;
        protected var m_growTime:Number;
        protected var m_buildTime:Number;
        protected var m_allowWither:Boolean;
        protected var m_sizeX:int;
        protected var m_sizeY:int;
        protected var m_startDate:Number = NAN;
        protected var m_endDate:Number = NAN;
        protected var m_showTimer:Boolean = false;
        protected var m_imageOffsetX:Number;
        protected var m_imageOffsetY:Number;
        protected var m_peoplePerHarvest:int;
        protected var m_peoplePerPlant:int;
        protected var m_actionsPerPerson:int;
        protected var m_size:int;
        protected var m_ownable:Boolean;
        protected var m_commodities:Array;
        protected var m_maxPlots:Number;
        protected var m_bonusPercent:Number;
        protected var m_waterLength:Number;
        protected var m_landSquares:String;
        protected var m_dockSquares:String;
        protected var m_berthSquares:String;
        protected var m_freeShipSquares:String;
        protected var m_freeShipType:String;
        protected var m_emptyNPCType:String;
        protected var m_loadedNPCType:String;
        protected var m_requiredShip:String;
        protected var m_energyRewards:Number;
        protected var m_cashRewards:Number;
        protected var m_coinRewards:Number;
        protected var m_goodsReward:Number;
        protected var m_itemRewards:Array;
        protected var m_randomRewards:Array;
        protected var m_foodConsumption:int;
        protected var m_goodsConsumption:int;
        protected var m_populationBase:Number;
        protected var m_populationMax:Number;
        protected var m_populationCapYield:Number;
        protected var m_headquartersName:String;
        protected var m_heightLimit:Number;
        protected var m_canFranchise:Boolean;
        protected var m_franchiseSaleCommCost:int;
        protected var m_clickSound:String;
        protected var m_commodityReq:Number;
        protected var m_trainTripTime:uint;
        protected var m_trainStorage:int;
        protected var m_trainMinStops:int;
        protected var m_trainSpeedUpCost:int;
        protected var m_trainBuyPrice:Number;
        protected var m_trainSellPrice:Number;
        protected var m_trainDestination:String;
        protected var m_trainPayout:String;
        protected var m_validGiftTimeRangeStart:String;
        protected var m_themeListeners:Dictionary;
        protected var m_validGiftTimeRangeEnd:String;
        protected var m_themeCollection:Array;
        protected var m_toggling:Boolean;
        protected var m_isToggled:Function;
        protected var toggleFuncs:Object;
        protected var m_InventoryLimit:int = -1;
        protected var m_UnwrapIcon:String;
        protected var m_storable:Boolean;
        protected var m_storageType:String = null;
        protected var m_storageKey:String = null;
        protected var m_storageInitCapacity:int = -1;
        protected var m_storageMaxCapacity:int = -1;
        protected var m_workers:WorkersDefinition;
        protected var m_harvestBonuses:Vector.<HarvestBonus>;
        protected var m_upgrade:UpgradeDefinition;
        protected var m_upgradedFromItemName:String = "## unknown item name ##";
        protected var m_upgradeRootName:String = "## unknown item name ##";
        protected var m_feed:String;
        protected var m_spawnNpcs:Array;
        protected var m_spawnNpcWeights:Array;
        protected var m_maxSpawnNpcWeight:int;
        protected var m_placeableOn:String;
        protected var m_canPlaceToFriendHome:String;
        protected var m_expireTime:Number;
        protected var m_phases:Array;
        protected var m_rarity:String;
        protected var m_unlocksItem:String;
        protected var m_displayLocations:DisplayLocationsDefinition;
        protected var m_isPixelInsideAlphaThresholdOveride:uint = 128;
        protected var m_showGirders:int;
        protected var m_item_bridgeDefn:ItemDefinitionBridge;
        protected var m_floorMysteryBusiness:String;
        protected var m_keywords:Array;
        protected var m_derivedItem:String;

        public function Item(_arg1:XML){
            var imageDef:* = null;
            var typeIdx:* = 0;
            var harvestBonusXML:* = null;
            var validationXml:* = null;
            var themeXML:* = null;
            var keywordXML:* = null;
            var phrase:* = null;
            var animationSetName:* = null;
            var textureDefName:* = null;
            var animationSet:* = null;
            var textureDef:* = null;
            var textureAsset:* = undefined;
            var img:* = null;
            var copy:* = null;
            var subimage:* = null;
            var image:* = null;
            var rowLength:* = 0;
            var rowIdx:* = 0;
            var str:* = null;
            var charIdx:* = 0;
            var char:* = null;
            var ticker:* = null;
            var tickerName:* = null;
            var toaster:* = null;
            var toasterName:* = null;
            var toasterAsset:* = null;
            var toasterImage:* = null;
            var bonus:* = null;
            var bonusName:* = null;
            var harvestBonus:* = null;
            var script:* = null;
            var theme:* = null;
            var experimentDefinition:* = null;
            var eligibleVariants:* = null;
            var explodedVariants:* = null;
            var explodedVariant:* = null;
            var sum:* = 0;
            var npc:* = null;
            var commod:* = null;
            var data:* = null;
            var itemReward:* = null;
            var def:* = null;
            var randItem:* = null;
            var phraseData:* = null;
            var endDateStr:* = null;
            var showTimer:* = null;
            var startDateStr:* = null;
            var xml:* = _arg1;
            this.m_cachedImages = [];
            this.m_collisionData = [];
            this.m_bonuses = [];
            this.m_validations = new Dictionary(false);
            this.toggleFuncs = {theme_collection:Global.world.isThemeCollectionEnabled};
            this.m_item_bridgeDefn = new ItemDefinitionBridge();
            xml = this.preprocessXML(xml);
            super(xml);
            this.m_themeListeners = new Dictionary();
            var imageDefinitions:* = [];
            for each (imageDef in m_xml.image) {
                imageDefinitions.push(imageDef);
            };
            if (xml.hasOwnProperty("displayLocations")){
                this.m_displayLocations = new DisplayLocationsDefinition();
                this.m_displayLocations.loadObject(xml.child("displayLocations")[0]);
            };
            if (xml.imageGenerator.length() > 0){
                animationSetName = m_xml.imageGenerator.animationSet.@name;
                textureDefName = m_xml.imageGenerator.texture.@name;
                animationSet = Global.gameSettings.getXML().animationDirectory.animationSet.(@name == animationSetName);
                textureDef = Global.gameSettings.getXML().textureDirectory.texture.(@name == textureDefName);
                if ((((animationSet.length() == 1)) && ((textureDef.length() == 1)))){
                    textureAsset = textureDef[0].asset[0];
                    for each (img in animationSet.image) {
                        copy = img.copy();
                        subimage = copy.image[0];
                        subimage.appendChild(textureAsset.copy());
                        imageDefinitions.push(copy);
                    };
                } else {
                    ErrorManager.addError(("Failed to process imageGenerator definition for " + xml.@name));
                };
            };
            for each (imageDef in imageDefinitions) {
                image = new ItemImage(imageDef);
                image.is_root = true;
                if (xml.@type.toString() == "road"){
                    image.is_road = true;
                };
                image.addEventListener(LoaderEvent.LOADED, this.onImageLoaded);
                this.m_cachedImages.push(image);
            };
            typeIdx = 0;
            while (typeIdx < m_xml.collision.length()) {
                this.m_collisionData.push(new Array());
                rowLength = m_xml.collision[typeIdx].r.length();
                rowIdx = 0;
                while (rowIdx < m_xml.collision[typeIdx].r.length()) {
                    str = m_xml.collision[typeIdx].r[rowIdx];
                    charIdx = 0;
                    while (charIdx < str.length) {
                        char = str.charAt(charIdx);
                        this.m_collisionData[typeIdx].push(this.getCollisionFlagsFromChar(char));
                        charIdx = (charIdx + 1);
                    };
                    rowIdx = (rowIdx + 1);
                };
                typeIdx = (typeIdx + 1);
            };
            if (this.m_collisionData.length == 0){
                this.m_collisionData.push(new Array());
            };
            this.m_acceptBonus = !((xml.@acceptBonus == false));
            if (((m_xml.hasOwnProperty("tickers")) && (!((m_xml.tickers.length() == 0))))){
                this.m_tickers = new Dictionary();
                for each (ticker in m_xml.tickers.ticker) {
                    tickerName = String(ticker.@name);
                    if (tickerName.length != 0){
                        this.m_tickers[tickerName] = {
                            name:tickerName,
                            text:String(ticker.@text)
                        };
                    };
                };
            };
            if (((m_xml.hasOwnProperty("toasters")) && (!((m_xml.toasters.length() == 0))))){
                this.m_toasters = new Dictionary();
                for each (toaster in m_xml.toasters.toaster) {
                    toasterName = String(toaster.@name);
                    if (toasterName.length != 0){
                        toasterAsset = null;
                        if (((toaster.hasOwnProperty("image")) && (!((toaster.image.length() == 0))))){
                            toasterImage = toaster.image[0];
                            toasterAsset = toaster.image[0].@url;
                        };
                        this.m_toasters[toasterName] = {
                            name:toasterName,
                            title:String(toaster.@title),
                            text:String(toaster.@text),
                            asset:toasterAsset
                        };
                    };
                };
            };
            var bonusIdx:* = 0;
            while (bonusIdx < m_xml.bonuses.bonus.length()) {
                bonus = new ItemBonus(m_xml.bonuses.bonus[bonusIdx]);
                this.m_bonuses.push(bonus);
                bonusIdx = (bonusIdx + 1);
            };
            var harvestBonusFactory:* = new HarvestBonusFactory();
            harvestBonusFactory.register("workerBonus", WorkerBonus);
            harvestBonusFactory.register("mallBonus", MallBonus);
            this.m_harvestBonuses = new Vector.<HarvestBonus>();
            for each (harvestBonusXML in m_xml.harvestBonuses.bonus) {
                bonusName = harvestBonusXML.@name;
                harvestBonus = harvestBonusFactory.createBonus(bonusName, harvestBonusXML);
                this.m_harvestBonuses.push(harvestBonus);
            };
            for each (validationXml in m_xml.validate) {
                script = Global.gameSettings.parseValidateTag(validationXml);
                if (script){
                    this.m_validations[script.name] = script;
                };
            };
            this.m_themeCollection = new Array();
            for each (themeXML in m_xml.toggleThemes.theme) {
                theme = Theme.loadObject(themeXML);
                this.m_themeCollection.push(theme);
            };
            this.m_keywords = new Array();
            for each (keywordXML in m_xml.keyword) {
                this.m_keywords.push(String(keywordXML));
            };
            m_name = xml.@name;
            this.m_localizedName = ZLoc.t(this.getFriendlyNameLocFile(), (name + "_friendlyName"));
            this.m_code = xml.@code;
            this.m_category = xml.@category;
            this.m_type = xml.@type;
            this.m_behavior = xml.@behavior;
            this.m_subtype = xml.@subtype;
            this.m_className = ((xml.@className.toString())!="") ? xml.@className : null;
            this.m_derivedItem = ((xml.@derivesFrom.toString())!="") ? xml.derivesFrom : null;
            this.m_buyable = !((xml.@buyable == false));
            this.m_placeable = (xml.@placeable == true);
            this.m_requestOnly = (xml.attribute("requestOnly") == true);
            this.m_persistent = (xml.@persistent == true);
            this.m_consumable = (xml.@consumable == true);
            this.m_ownable = !((xml.@ownable == false));
            this.m_giftable = !((xml.@giftable == false));
            this.m_noMarket = (xml.@noMarket == true);
            this.m_storable = !((xml.@storable == false));
            this.m_newTabPriority = (xml.@newTabPriority == true);
            this.m_level = ((int(xml.level) > 0)) ? xml.level : 1;
            this.m_coinYield = xml.coinYield;
            this.m_xpYield = xml.xpYield;
            this.m_populationBase = xml.populationBase;
            this.m_populationMax = xml.populationMax;
            this.m_populationCapYield = xml.populationCapYield;
            this.m_buildTime = xml.buildTime;
            this.m_growTime = xml.growTime;
            this.m_truckNum = xml.delivery.@count;
            this.m_canFranchise = (xml.canFranchise == true);
            this.m_franchiseSaleCommCost = xml.franchiseSaleCommCost;
            this.m_commodityReq = xml.commodityReq;
            this.m_feed = String(xml.feed);
            this.m_trainTripTime = xml.trainTripTime;
            this.m_trainStorage = xml.trainStorage;
            this.m_trainMinStops = xml.trainMinStops;
            this.m_trainSpeedUpCost = xml.trainSpeedUpCost;
            this.m_trainSellPrice = xml.trainSellPrice;
            this.m_trainBuyPrice = xml.trainBuyPrice;
            this.m_trainDestination = xml.trainDestination;
            this.m_trainPayout = String(xml.trainPayout.@table);
            this.m_rarity = xml.rarity;
            this.m_unlocksItem = xml.unlocksItem;
            var experimentDefinitions:* = xml.child("experiments").child("experiment");
            if (experimentDefinitions.length() > 0){
                this.m_experiments = new Dictionary();
                for each (experimentDefinition in experimentDefinitions) {
                    if (experimentDefinition.attribute("name").length() > 0){
                        eligibleVariants = [];
                        if (experimentDefinition.attribute("variants").length() > 0){
                            explodedVariants = experimentDefinition.attribute("variants").toString().split(",");
                            for each (explodedVariant in explodedVariants) {
                                eligibleVariants.push(parseInt(explodedVariant));
                            };
                        } else {
                            eligibleVariants.push(1);
                        };
                        this.m_experiments[experimentDefinition.attribute("name").toString()] = eligibleVariants;
                    };
                };
            };
            if (xml.hasOwnProperty("energyCost")){
                this.m_buildEnergyCost = xml.energyCost.@build;
                this.m_harvestEnergyCost = xml.energyCost.@harvest;
                this.m_plantEnergyCost = xml.energyCost.@plant;
                this.m_cleanEnergyCost = xml.energyCost.@clean;
                this.m_clearEnergyCost = xml.energyCost.@clear;
                this.m_openEnergyCost = xml.energyCost.@open;
                this.m_instantFinishEnergyCost = xml.energyCost.@instantFinish;
                this.m_unlockMovementEnergyCost = xml.energyCost.@unlockMovement;
            };
            if (xml.hasOwnProperty("clearReward")){
                this.m_clearXpReward = m_xml.clearReward.@xp;
                this.m_clearGoldReward = m_xml.clearReward.@gold;
            };
            if (xml.hasOwnProperty("plots")){
                this.m_maxPlots = xml.plots;
            };
            if (((xml.hasOwnProperty("upgrade")) && (((xml.upgrade as XMLList).length() > 0)))){
                GlobalEngine.assert(((xml.upgrade as XMLList).length() == 1), "Invalid XML upgrade definition!");
                this.m_upgrade = new UpgradeDefinition(m_name, xml.upgrade[0]);
            };
            this.m_spawnNpcs = [];
            this.m_spawnNpcWeights = [];
            if (xml.hasOwnProperty("npcInfo")){
                this.m_peoplePerHarvest = m_xml.npcInfo.@npcsPerHarvest;
                this.m_peoplePerPlant = m_xml.npcInfo.@npcsPerPlant;
                this.m_actionsPerPerson = m_xml.npcInfo.@actionsPerNpc;
                this.m_maxSpawnNpcWeight = int(m_xml.npcInfo.@maxWeight);
                if (this.m_maxSpawnNpcWeight > 0){
                    sum = 0;
                    for each (npc in xml.npcInfo.npc) {
                        this.m_spawnNpcs.push(String(npc.@type));
                        this.m_spawnNpcWeights.push(int(npc.@probability));
                        sum = (sum + int(npc.@probability));
                    };
                    if (sum >= this.m_maxSpawnNpcWeight){
                        this.m_maxSpawnNpcWeight = sum;
                    } else {
                        this.m_spawnNpcs.push("");
                        this.m_spawnNpcWeights.push((this.m_maxSpawnNpcWeight - sum));
                    };
                };
            } else {
                this.m_peoplePerHarvest = Global.gameSettings.getInt("npcsDefaultPerHarvest");
                this.m_peoplePerPlant = Global.gameSettings.getInt("npcsDefaultPerPlant");
            };
            if (xml.hasOwnProperty("commodity")){
                this.m_commodities = new Array();
                for each (commod in xml.commodity) {
                    data = {
                        name:String(commod.@name),
                        capacity:int(commod.@capacity),
                        produces:int(commod.@produces),
                        default:Boolean((commod.@default == "1"))
                    };
                    this.m_commodities.push(data);
                };
            } else {
                this.m_commodities = new Array();
            };
            if (xml.hasOwnProperty("bonuses")){
                this.m_bonusPercent = xml.bonuses.bonus.@percentModifier;
            };
            if (xml.hasOwnProperty("storageUnit")){
                this.m_storageType = xml.storageUnit["storageType"];
                this.m_storageKey = xml.storageUnit["storageKey"];
                this.m_storageInitCapacity = xml.storageUnit["initialCapacity"];
                this.m_storageMaxCapacity = xml.storageUnit["maxCapacity"];
            };
            if (xml.hasOwnProperty("storageParams")){
                if (xml.storageParams.length() > 1){
                    ErrorManager.addError("ERROR: Items can only have one storageParams defined!");
                };
            };
            if (xml.hasOwnProperty("workers")){
                this.m_workers = new WorkersDefinition();
                this.m_workers.loadObject(xml.workers[0]);
            };
            this.m_headquartersName = (xml.hasOwnProperty("headquarters")) ? xml.headquarters : null;
            this.m_heightLimit = (xml.hasOwnProperty("heightLimit")) ? xml.heightLimit : -1;
            this.m_dailyCollect = xml.dailyCollect;
            this.m_energyRewards = xml.energyRewards;
            this.m_goodsReward = xml.goodsReward;
            this.m_cashRewards = xml.cashRewards;
            this.m_coinRewards = xml.coinRewards;
            this.m_itemRewards = [];
            var itemNameIdx:* = 0;
            while (itemNameIdx < xml.itemRewards.itemName.length()) {
                itemReward = String(xml.itemRewards.itemName[itemNameIdx]);
                this.m_itemRewards.push(itemReward);
                itemNameIdx = (itemNameIdx + 1);
            };
            if (xml.hasOwnProperty("randomRewards")){
                this.m_randomRewards = [];
                for each (def in xml.randomRewards.randItem) {
                    randItem = Global.gameSettings.getItemByName(def.@name);
                    this.m_randomRewards.push(randItem);
                };
            };
            var allowWither:* = xml.@allowWither;
            this.m_allowWither = !((((allowWither.length > 0)) && ((allowWither == "false"))));
            this.m_cost = xml.cost;
            this.m_cash = xml.cash;
            this.m_goods = xml.goods;
            this.m_fbc = xml.fbc;
            this.m_sale = xml.sale;
            this.m_sizeX = xml.sizeX;
            this.m_sizeY = xml.sizeY;
            this.m_imageOffsetX = xml.imageOffsetX;
            this.m_imageOffsetY = xml.imageOffsetY;
            this.m_requiredLevel = xml.requiredLevel;
            this.m_expireTime = xml.expireTime;
            this.m_phases = [];
            for each (phrase in xml.phases.children()) {
                phraseData = {
                    ord:Number(phrase.@ord),
                    duration:Number(phrase.@duration),
                    rate:Number(phrase.@rate),
                    canHavest:Boolean(phrase.@canHavest)
                };
                this.m_phases.push(phraseData);
            };
            if (xml.endDate.length() > 0){
                endDateStr = xml.endDate;
                this.m_endDate = DateFormatter.parseTimeString(endDateStr);
                if (xml.showTimer.length() > 0){
                    showTimer = xml.showTimer;
                    if (showTimer == "true"){
                        this.m_showTimer = true;
                    };
                };
            };
            if (xml.startDate.length() > 0){
                startDateStr = xml.startDate;
                this.m_startDate = DateFormatter.parseTimeString(startDateStr);
            };
            this.m_requiredPopulation = xml.requiredPopulation;
            this.m_requiredNeighbors = xml.requiredNeighbors;
            this.m_requiredQuestFlag = xml.requiredQuestFlag;
            this.m_requiredSeenFlag = xml.requiredSeenFlag;
            this.m_unlock = ((String(xml.unlock))!="") ? String(xml.unlock) : UNLOCK_LEVEL;
            this.m_unlockCost = int(xml.unlockCost);
            this.m_unlockShareFunc = String(xml.unlockShareFunc);
            this.m_size = xml.@size;
            this.m_noAutoScale = xml.noAutoScale;
            this.m_noAutoRotate = (xml.noAutoRotate == 1);
            this.m_imageScale = xml.imageScale;
            this.m_market = String(m_xml.@market);
            this.m_multiplace = (m_xml.@multiplace == true);
            this.m_multiplant = !((m_xml.@multiplant == false));
            this.m_useTileHighlight = (m_xml.@useTileHighlight == true);
            this.m_special_onclick = String(m_xml.@special_onclick);
            this.m_useTilePicking = (m_xml.@useTilePicking == true);
            this.m_sellSendsToInventory = (m_xml.@sellSendsToInventory == true);
            this.m_construction = ((m_xml.construction.length())>0) ? String(m_xml.construction) : null;
            this.m_toggling = (m_xml.@toggling == "true");
            this.m_isToggled = (this.m_toggling) ? this.toggleFuncs[this.type] : null;
            this.m_waterLength = xml.waterlength;
            this.m_landSquares = ((m_xml.docksquares.length())>0) ? String(m_xml.docksquares) : null;
            this.m_dockSquares = ((m_xml.docksquares.length())>0) ? String(m_xml.docksquares) : null;
            this.m_berthSquares = ((m_xml.berthsquares.length())>0) ? String(m_xml.berthsquares) : null;
            this.m_freeShipSquares = ((m_xml.freeShipSquares.length())>0) ? String(m_xml.freeShipSquares) : null;
            this.m_freeShipType = ((m_xml.freeShipType.length())>0) ? String(m_xml.freeShipType) : null;
            this.m_requiredShip = ((m_xml.requiredShip.length())>0) ? String(m_xml.requiredShip) : null;
            this.m_emptyNPCType = ((m_xml.emptyNPCType.length())>0) ? String(m_xml.emptyNPCType) : null;
            this.m_loadedNPCType = ((m_xml.loadedNPCType.length())>0) ? String(m_xml.loadedNPCType) : null;
            this.m_clickSound = ((m_xml.clickSound.length())>0) ? String(m_xml.clickSound) : null;
            this.m_validGiftTimeRangeStart = ((m_xml.validGiftTimeRangeStart.length())>0) ? String(m_xml.validGiftTimeRangeStart) : null;
            this.m_validGiftTimeRangeEnd = ((m_xml.validGiftTimeRangeEnd.length())>0) ? String(m_xml.validGiftTimeRangeEnd) : null;
            this.m_InventoryLimit = (xml.hasOwnProperty("inventoryLimit")) ? xml.inventoryLimit : -1;
            this.m_UnwrapIcon = ((m_xml.unwrapicon.length())>0) ? String(m_xml.unwrapicon) : null;
            this.m_placeableOn = m_xml.@placeableOn;
            this.m_canPlaceToFriendHome = m_xml.@canPlaceToFriendHome;
            this.m_isPixelInsideAlphaThresholdOveride = (xml.hasOwnProperty("isPixelInsideAlphaThresholdOveride")) ? xml.isPixelInsideAlphaThresholdOveride : 128;
            this.m_showGirders = (m_xml.hasOwnProperty("showGirders")) ? m_xml.showGirders : 1;
            this.m_item_bridgeDefn.init(m_xml);
            this.m_floorMysteryBusiness = ((m_xml.floorMysteryBusiness.length())>0) ? String(m_xml.floorMysteryBusiness) : null;
            this.initSet(xml);
        }
        public static function findUpgradeParent(_arg1:Item):String{
            var _local2:Item;
            if (_arg1.m_upgradedFromItemName == UNKNOWN_ITEM_NAME){
                _arg1.m_upgradedFromItemName = null;
                for each (_local2 in Global.gameSettings.getItemsByType(_arg1.type)) {
                    if (((((!((_local2 == _arg1))) && (!((_local2.upgrade == null))))) && ((_local2.upgrade.newItemName == _arg1.name)))){
                        _arg1.m_upgradedFromItemName = _local2.name;
                        break;
                    };
                };
            };
            return (_arg1.m_upgradedFromItemName);
        }
        public static function findUpgradeRoot(_arg1:Item):String{
            var _local2:Item;
            var _local3:String;
            var _local4:String;
            if (_arg1.m_upgradeRootName == UNKNOWN_ITEM_NAME){
                _local2 = _arg1;
                while (_local2 != null) {
                    _local3 = _local2.name;
                    _local4 = Item.findUpgradeParent(_local2);
                    _local2 = Global.gameSettings.getItemByName(_local4);
                };
                _arg1.m_upgradeRootName = _local3;
            };
            return (_arg1.m_upgradeRootName);
        }

        protected function initSet(_arg1:XML):void{
            var _local2:Boolean;
            var _local3:Set;
            if (("@set" in _arg1)){
                this.m_set = Global.gameSettings.getSetByName(_arg1.@set);
            } else {
                _local2 = false;
                for each (_local3 in Global.gameSettings.getSets()) {
                    if (_local3.isItemInSet(m_name)){
                        this.m_set = _local3;
                        _local2 = true;
                        break;
                    };
                };
                if (!_local2){
                    this.m_set = null;
                };
            };
        }
        protected function getCollisionFlagsFromChar(_arg1:String):int{
            var _local2:int;
            switch (_arg1){
                case "#":
                    _local2 = Constants.COLLISION_ALL;
                    break;
                case "O":
                    _local2 = Constants.COLLISION_OVERLAP;
                    break;
                case "H":
                    _local2 = Constants.COLLISION_ALL_EXCEPT_AVATAR;
                    break;
                case ".":
                default:
                    _local2 = Constants.COLLISION_NONE;
            };
            return (_local2);
        }
        public function getImageObjectFromCache():Object{
            var _local1:Object;
            var _local3:Object;
            var _local2:int;
            while (_local2 < this.m_cachedImages.length) {
                _local3 = this.m_cachedImages[_local2];
                if (_local3.name == "static"){
                    _local1 = _local3;
                    break;
                };
                _local2++;
            };
            return (_local1);
        }
        public function getCachedImage(_arg1:String, _arg2:MapResource=null, _arg3:int=0, _arg4:String=null):ItemImageInstance{
            var _local5:Item = Global.gameSettings.getItemByNameAndThemes(m_name, Global.world.currentThemes);
            if (_local5 == null){
                _local5 = this;
            } else {
                if (((!(this.m_themeListeners[_local5])) && (!((_local5 == this))))){
                    this.m_themeListeners[_local5] = true;
                    _local5.addEventListener(LoaderEvent.LOADED, this.onImageLoaded);
                };
            };
            return (_local5.getCanonicalCachedImage(_arg1, _arg2, _arg3, _arg4));
        }
        public function getCanonicalCachedImage(_arg1:String, _arg2:MapResource=null, _arg3:int=0, _arg4:String=null):ItemImageInstance{
            var _local5:ItemImageInstance;
            var _local7:ItemImage;
            var _local6:int;
            while (_local6 < this.m_cachedImages.length) {
                _local7 = (this.m_cachedImages[_local6] as ItemImage);
                if (((_local7) && (_local7.isMatching(_arg1, _arg3, _arg4)))){
                    _local5 = _local7.getInstance(_arg2);
                    if (((_local5) && ((_local5.image == null)))){
                        _local5 = null;
                    };
                };
                _local6++;
            };
            return (_local5);
        }
        public function isCachedImageLoading(_arg1:String, _arg2:int=0, _arg3:String=null):Boolean{
            var _local5:ItemImage;
            var _local4:int;
            while (_local4 < this.m_cachedImages.length) {
                _local5 = (this.m_cachedImages[_local4] as ItemImage);
                if (((_local5) && (_local5.isMatching(_arg1, _arg2, _arg3)))){
                    if (_local5.isLoading()){
                        return (true);
                    };
                };
                _local4++;
            };
            return (false);
        }
        public function getCachedImageHotspots(_arg1:String, _arg2:int=0, _arg3:String=""):Vector.<Vector3>{
            var _local5:ItemImage;
            var _local4:int;
            while (_local4 < this.m_cachedImages.length) {
                _local5 = (this.m_cachedImages[_local4] as ItemImage);
                if (((((_local5) && ((_local5.name == _arg1)))) && ((((_local5.direction == _arg2)) || (_local5.allDirections))))){
                    return (_local5.getHotspotsByName(_arg3));
                };
                _local4++;
            };
            return (null);
        }
        public function getCachedImageDimensions(_arg1:String, _arg2:int=0):Vector3{
            var _local4:ItemImage;
            var _local3:int;
            while (_local3 < this.m_cachedImages.length) {
                _local4 = (this.m_cachedImages[_local3] as ItemImage);
                if (((((_local4) && ((_local4.name == _arg1)))) && ((((_local4.direction == _arg2)) || (_local4.allDirections))))){
                    if ((((_local4.forcedWidth > 0)) && ((_local4.forcedHeight > 0)))){
                        return (new Vector3(_local4.forcedWidth, _local4.forcedHeight));
                    };
                    return (null);
                };
                _local3++;
            };
            return (null);
        }
        private function onImageLoaded(_arg1:Event):void{
            _arg1.stopImmediatePropagation();
            dispatchEvent(new LoaderEvent(LoaderEvent.LOADED));
        }
        public function get dailyCollect():int{
            return (this.m_dailyCollect);
        }
        public function get level():int{
            return (this.m_level);
        }
        public function get requiredLevel():uint{
            return (this.m_requiredLevel);
        }
        public function get type():String{
            return (this.m_type);
        }
        public function get subtype():String{
            return (this.m_subtype);
        }
        public function get bonuses():Array{
            return (this.m_bonuses);
        }
        public function get acceptBonus():Boolean{
            return (this.m_acceptBonus);
        }
        public function getTickerInfo(_arg1:String):Object{
            var _local2:Object;
            if (((((this.m_tickers) && (_arg1))) && (this.m_tickers[_arg1]))){
                _local2 = this.m_tickers[_arg1];
            };
            return (_local2);
        }
        public function getToasterInfo(_arg1:String):Object{
            var _local2:Object;
            if (((((this.m_toasters) && (_arg1))) && (this.m_toasters[_arg1]))){
                _local2 = this.m_toasters[_arg1];
            };
            return (_local2);
        }
        public function getValidation(_arg1:String):GenericValidationScript{
            return (this.m_validations[_arg1]);
        }
        public function get harvestBonuses():Vector.<HarvestBonus>{
            return (this.m_harvestBonuses);
        }
        public function get behavior():String{
            return (this.m_behavior);
        }
        public function get multiplace():Boolean{
            return (this.m_multiplace);
        }
        public function get multiplant():Boolean{
            return (this.m_multiplant);
        }
        public function get giftable():Boolean{
            return (this.m_giftable);
        }
        public function get market():String{
            return (this.m_market);
        }
        public function get unlock():String{
            return (this.m_unlock);
        }
        public function set unlockCost(_arg1:Number):void{
            this.m_unlockCost = _arg1;
        }
        public function get unlockShareFunc():String{
            return (this.m_unlockShareFunc);
        }
        public function get unlockCost():Number{
            return (this.m_unlockCost);
        }
        public function get sale():int{
            return (this.m_sale);
        }
        public function get requiredPopulation():int{
            return (this.m_requiredPopulation);
        }
        public function get requiredPopulationScaled():int{
            return ((this.m_requiredPopulation * Global.gameSettings.getNumber("populationScale", 1)));
        }
        public function get requiredNeighbors():int{
            return (this.m_requiredNeighbors);
        }
        public function get requiredQuestFlag():String{
            return (this.m_requiredQuestFlag);
        }
        public function get requiredSeenFlag():String{
            return (this.m_requiredSeenFlag);
        }
        public function get className():String{
            return (this.m_className);
        }
        public function get icon():String{
            return (getImageByName("icon"));
        }
        public function get iconRelative():String{
            return (getRelativeImageByName("icon"));
        }
        public function get cost():int{
            if (((Global.isVisiting()) && ((this.type == "business")))){
                return ((this.m_cost * (1 - (Global.gameSettings.getInt("franchiseDiscountPct") / 100))));
            };
            if (this.type == "expansion"){
                return ((this.m_cost * ExpansionManager.instance.getNextExpansionPurchaseMultiplier()));
            };
            return (this.m_cost);
        }
        public function get cash():int{
            if (((Global.isVisiting()) && ((this.type == "business")))){
                return ((this.m_cash * (1 - (Global.gameSettings.getInt("franchiseDiscountPct") / 100))));
            };
            return (this.m_cash);
        }
        public function get goods():int{
            return (this.m_goods);
        }
        public function get fbc():int{
            return (this.m_fbc);
        }
        public function GetItemCost():int{
            if (this.goods > 0){
                return (this.goods);
            };
            if (this.cash > 0){
                return (this.cash);
            };
            if (this.fbc > 0){
                return (this.fbc);
            };
            return (this.cost);
        }
        public function GetItemSalePrice():int{
            var _local1:Number = this.GetItemCost();
            var _local2:Number = (this.sale / 100);
            _local1 = Math.ceil((_local1 - (_local1 * _local2)));
            _local1 = int(_local1.toFixed(0));
            return (_local1);
        }
        public function get plantXp():int{
            return (Global.gameSettings.getInt("buyXpGainMin"));
        }
        public function get growTime():Number{
            return (this.m_growTime);
        }
        public function buildTimeInDays():Number{
            var _local1:Item;
            var _local2:Number;
            var _local3:int;
            var _local4:int;
            var _local5:int;
            var _local6:Number;
            if (this.construction != null){
                _local1 = Global.gameSettings.getItemByName(this.m_construction);
                if (_local1 != null){
                    _local2 = _local1.xml.timePerBuild;
                    _local3 = _local1.xml.buildsPerStage;
                    _local4 = _local1.xml.numberOfStages;
                    _local5 = (_local3 * _local4);
                    _local6 = ((_local2 * _local5) / (((1000 * 60) * 60) * 24));
                    return (_local6);
                };
            };
            return (this.m_buildTime);
        }
        public function get allowWither():Boolean{
            return (this.m_allowWither);
        }
        public function get coinYield():int{
            return (this.m_coinYield);
        }
        public function get xpYield():int{
            return (this.m_xpYield);
        }
        public function get populationBase():int{
            return (this.m_populationBase);
        }
        public function get populationMax():int{
            return (this.m_populationMax);
        }
        public function get populationCapYield():int{
            return (this.m_populationCapYield);
        }
        public function get harvestEnergyCost():int{
            return (this.m_harvestEnergyCost);
        }
        public function get buildEnergyCost():int{
            return (this.m_buildEnergyCost);
        }
        public function get cleanEnergyCost():int{
            return (this.m_cleanEnergyCost);
        }
        public function get plantEnergyCost():int{
            return (this.m_plantEnergyCost);
        }
        public function get clearEnergyCost():int{
            return (this.m_clearEnergyCost);
        }
        public function get unlockMovementEnergyCost():int{
            return (this.m_unlockMovementEnergyCost);
        }
        public function get openEnergyCost():int{
            return (this.m_openEnergyCost);
        }
        public function get instantFinishEnergyCost():int{
            return (this.m_instantFinishEnergyCost);
        }
        public function get clearXpReward():int{
            return (this.m_clearXpReward);
        }
        public function get clearGoldReward():int{
            return (this.m_clearGoldReward);
        }
        public function get contractChoices():Array{
            return (String(m_xml.contracts).split(","));
        }
        public function get buyable():Boolean{
            return (this.m_buyable);
        }
        public function get experiments():Dictionary{
            return (this.m_experiments);
        }
        public function get noMarket():Boolean{
            return (this.m_noMarket);
        }
        public function get placeable():Boolean{
            return (this.m_placeable);
        }
        public function get requestOnly():Boolean{
            return (this.m_requestOnly);
        }
        public function get persistent():Boolean{
            return (this.m_persistent);
        }
        public function get consumable():Boolean{
            return (this.m_consumable);
        }
        public function get npcsPerHarvest():Number{
            return (this.m_peoplePerHarvest);
        }
        public function get npcsPerPlant():Number{
            return (this.m_peoplePerPlant);
        }
        public function get actionsPerNpc():int{
            return (this.m_actionsPerPerson);
        }
        public function get ownable():Boolean{
            return (this.m_ownable);
        }
        public function get storable():Boolean{
            return (this.m_storable);
        }
        public function get workers():WorkersDefinition{
            return (this.m_workers);
        }
        public function get displayLocations():DisplayLocationsDefinition{
            return (this.m_displayLocations);
        }
        public function get canFranchise():Boolean{
            return (this.m_canFranchise);
        }
        public function get franchiseSaleCommCost():int{
            return (this.m_franchiseSaleCommCost);
        }
        public function get commodityReq():Number{
            return (this.m_commodityReq);
        }
        public function get useTileHighlight():Boolean{
            return (this.m_useTileHighlight);
        }
        public function get useTilePicking():Boolean{
            return (this.m_useTilePicking);
        }
        public function get sellSendsToInventory():Boolean{
            return (this.m_sellSendsToInventory);
        }
        public function get sellPrice():int{
            var _local1:Number = Global.gameSettings.getNumber("sellBackRatio");
            return (Math.ceil((this.cost * _local1)));
        }
        public function get code():String{
            return (this.m_code);
        }
        override public function get localizedName():String{
            if (((((this.m_toggling) && (this.m_isToggled))) && (this.m_isToggled(this)))){
                return (ZLoc.t(this.getFriendlyNameLocFile(), (name + "_friendlyName_disable")));
            };
            return (this.m_localizedName);
        }
        public function getLocalizedObjectToken(_arg1:int=1):LocalizationObjectToken{
            return (ZLoc.tk(this.getObjectTokenLocFile(), ("Item_" + name), "", _arg1));
        }
        public function get iconImageName():String{
            if (((((this.m_toggling) && (this.m_isToggled))) && (this.m_isToggled(this)))){
                return ("icon_disable");
            };
            return ("icon");
        }
        public function get toggling():Boolean{
            return (this.m_toggling);
        }
        public function set localizedName(_arg1:String):void{
            this.m_localizedName = _arg1;
        }
        public function get sizeX():Number{
            return (Math.max(this.m_sizeX, 0.01));
        }
        public function get sizeY():Number{
            return (Math.max(this.m_sizeY, 0.01));
        }
        public function get noAutoScale():Number{
            return (this.m_noAutoScale);
        }
        public function get noAutoRotate():Boolean{
            return (this.m_noAutoRotate);
        }
        public function get imageScale():Number{
            return (this.m_imageScale);
        }
        public function get imageOffsetX():Number{
            return (this.m_imageOffsetX);
        }
        public function get imageOffsetY():Number{
            return (this.m_imageOffsetY);
        }
        public function getCollisionData(_arg1:int=0):Array{
            return (this.m_collisionData[_arg1]);
        }
        public function get itemRewards():Array{
            return (this.m_itemRewards);
        }
        public function get randomRewards():Array{
            return (this.m_randomRewards);
        }
        public function get energyRewards():Number{
            return (this.m_energyRewards);
        }
        public function get cashRewards():Number{
            return (this.m_cashRewards);
        }
        public function get coinRewards():Number{
            return (this.m_coinRewards);
        }
        public function get goodsReward():Number{
            return (this.m_goodsReward);
        }
        public function getCollisionDataIndexByName(_arg1:String):int{
            var _local2 = -1;
            var _local3:int;
            while (_local3 < m_xml.collision.length()) {
                if (m_xml.collision[_local3].@name == _arg1){
                    _local2 = _local3;
                    break;
                };
                _local3++;
            };
            return (_local2);
        }
        public function getSet():Set{
            return (this.m_set);
        }
        public function get showTimer():Boolean{
            return (this.m_showTimer);
        }
        public function get startDate():Number{
            return (this.m_startDate);
        }
        public function get endDate():Number{
            return (this.m_endDate);
        }
        public function get construction():String{
            return (this.m_construction);
        }
        public function get constructionXml():XML{
            if (m_xml.construction.length() > 0){
                return (m_xml.construction[0]);
            };
            return (null);
        }
        public function get shockwaveXml():XMLList{
            return (m_xml.shockwave);
        }
        public function get expansionWidth():Number{
            return (m_xml.@width);
        }
        public function get expansionHeight():Number{
            return (m_xml.@height);
        }
        public function get gatesXml():XMLList{
            return (m_xml["gates"]);
        }
        public function getCurrentCrewGateXML(_arg1:MapResource):XMLList{
            var crewDefItem:* = null;
            var owner:* = _arg1;
            var parent:* = null;
            var gatesxml:* = null;
            var parentName:* = Item.findUpgradeParent(this);
            if (parentName){
                parent = Global.gameSettings.getItemByName(parentName);
            };
            var rollCallMechanic:* = null;
            if ((owner is IMechanicUser)){
                rollCallMechanic = (MechanicManager.getInstance().getMechanicInstance((owner as IMechanicUser), "rollCall", MechanicManager.ALL) as RollCallDataMechanic);
            };
            var rollCallInProgress:* = ((((rollCallMechanic) && ((rollCallMechanic.getState() == RollCallDataMechanic.STATE_IN_PROGRESS)))) && ((rollCallMechanic.getRollCallTimeLeft() > 0)));
            if (rollCallInProgress){
                if (parent){
                    gatesxml = parent.gatesXml.gate.(@name == "pre_upgrade");
                } else {
                    gatesxml = this.gatesXml.gate.(@name == "build");
                };
            } else {
                crewDefItem = (this.upgrade.newItemName) ? this : parent;
                if (((crewDefItem) && (((owner.isUpgradePossible()) || ((this.gatesXml.gate.(@name == "build").length() < 1)))))){
                    gatesxml = crewDefItem.gatesXml.gate.(@name == "pre_upgrade");
                } else {
                    gatesxml = this.gatesXml.gate.(@name == "build");
                };
            };
            return (gatesxml);
        }
        public function get randomModifiersXml():XML{
            var randMods:* = m_xml.randomModifiers;
            if ((((randMods.length() > 0)) && (randMods.hasOwnProperty("@name")))){
                return (randMods.(@name == "default")[0]);
            };
            return (randMods[0]);
        }
        public function get randomModifiersXmlList():XMLList{
            return (m_xml.randomModifiers);
        }
        public function getRandomModifiersXmlByName(_arg1:String):XML{
            var modifiersName:* = _arg1;
            var table:* = null;
            if ((((this.randomModifiersXmlList.length() > 0)) && (this.randomModifiersXmlList.hasOwnProperty("@name")))){
                table = this.randomModifiersXmlList.(@name == modifiersName)[0];
            };
            return (table);
        }
        public function get special_onclick():String{
            if (this.m_special_onclick){
                return (this.m_special_onclick);
            };
            return (null);
        }
        public function get randomModifierGroupsXml():XMLList{
            return (m_xml.randomModifierGroups.group);
        }
        public function get navigateXml():XMLList{
            var _local1:Item = Global.gameSettings.getItemByNameAndThemes(m_name, Global.world.currentThemes);
            if (_local1 == null){
                _local1 = this;
            };
            return (_local1.xml.navigate);
        }
        public function get smokeXml():XMLList{
            return (m_xml.smoke);
        }
        public function get deliveryXml():XMLList{
            return (m_xml.delivery);
        }
        public function get commodityXml():XML{
            var result:* = null;
            if (m_xml.commodity.length() > 1){
                result = m_xml.commodity.(@default == "1");
            } else {
                if (m_xml.commodity.length() > 0){
                    result = m_xml.commodity[0];
                };
            };
            return (result);
        }
        private function getDefaultCommodity():Object{
            var _local1:Object;
            if (this.m_commodities.length > 1){
                for each (_local1 in this.m_commodities) {
                    if (_local1.default){
                        return (_local1);
                    };
                };
            } else {
                if (this.m_commodities.length > 0){
                    return (this.m_commodities[0]);
                };
            };
            return (null);
        }
        public function get commodityName():String{
            var _local1 = "";
            var _local2:Object = this.getDefaultCommodity();
            if (_local2){
                _local1 = _local2.name;
            };
            return (_local1);
        }
        public function get commodityCapacity():Number{
            var _local1:Number = 0;
            var _local2:Object = this.getDefaultCommodity();
            if (_local2){
                _local1 = _local2.capacity;
            };
            return (_local1);
        }
        public function get commodityProduction():Number{
            var _local1:Number = 0;
            var _local2:Object = this.getDefaultCommodity();
            if (_local2){
                _local1 = _local2.produces;
            };
            return (_local1);
        }
        public function get commodities():Array{
            return (this.m_commodities);
        }
        public function get foodConsumption():Number{
            return (this.m_foodConsumption);
        }
        public function get goodsConsumption():Number{
            return (this.m_goodsConsumption);
        }
        public function get maxPlots():Number{
            return (this.m_maxPlots);
        }
        public function get bonusPercent():Number{
            return (this.m_bonusPercent);
        }
        public function get waterLength():Number{
            return (this.m_waterLength);
        }
        public function get landSquares():String{
            return (this.m_landSquares);
        }
        public function get dockSquares():String{
            return (this.m_dockSquares);
        }
        public function get berthSquares():String{
            return (this.m_berthSquares);
        }
        public function get freeShipSquares():String{
            return (this.m_freeShipSquares);
        }
        public function get freeShipType():String{
            return (this.m_freeShipType);
        }
        public function get requiredShip():String{
            return (this.m_requiredShip);
        }
        public function get emptyNPCType():String{
            return (this.m_emptyNPCType);
        }
        public function get loadedNPCType():String{
            return (this.m_loadedNPCType);
        }
        public function get clickSound():String{
            return (this.m_clickSound);
        }
        public function get validGiftTimeRangeStart():String{
            return (this.m_validGiftTimeRangeStart);
        }
        public function get validGiftTimeRangeEnd():String{
            return (this.m_validGiftTimeRangeEnd);
        }
        public function get inventoryLimit():int{
            return (this.m_InventoryLimit);
        }
        public function get unwrapIcon():String{
            return (this.m_UnwrapIcon);
        }
        public function get playerLocked():Boolean{
            return (((!(m_xml.@playerLocked)) || ((m_xml.@playerLocked == false))));
        }
        public function get rawImageXml():XMLList{
            return (m_xml["image"]);
        }
        public function get storageType():String{
            return (this.m_storageType);
        }
        public function get storageKey():String{
            return (this.m_storageKey);
        }
        public function get storageInitCapacity():int{
            return (this.m_storageInitCapacity);
        }
        public function get storageMaxCapacity():int{
            return (this.m_storageMaxCapacity);
        }
        public function get upgrade():UpgradeDefinition{
            return (this.m_upgrade);
        }
        public function get derivedItemName():String{
            return (this.m_derivedItem);
        }
        public function get headquartersName():String{
            return (this.m_headquartersName);
        }
        public function get heightLimit():Number{
            return (this.m_heightLimit);
        }
        public function get trainTripTime():uint{
            return (this.m_trainTripTime);
        }
        public function get trainMinStops():int{
            return (this.m_trainMinStops);
        }
        public function get trainSpeedUpCost():int{
            return (this.m_trainSpeedUpCost);
        }
        public function get trainStorage():int{
            return (this.m_trainStorage);
        }
        public function get trainSellPrice():Number{
            return (this.m_trainSellPrice);
        }
        public function get trainBuyPrice():Number{
            return (this.m_trainBuyPrice);
        }
        public function get trainDestination():String{
            return (this.m_trainDestination);
        }
        public function get trainPayout():String{
            return (this.m_trainPayout);
        }
        public function get feed():String{
            return (this.m_feed);
        }
        public function get rarity():String{
            return (this.m_rarity);
        }
        public function get unlocksItem():String{
            return (this.m_unlocksItem);
        }
        public function getClass():Class{
            var _local1:Class = ItemClassDefinitions.getClassByItem(this);
            return (_local1);
        }
        override protected function getFriendlyNameLocFile():String{
            return ("Items");
        }
        protected function getObjectTokenLocFile():String{
            return ("Rewards");
        }
        public function addImageToCache(_arg1:Object):void{
            this.m_cachedImages.push(_arg1);
        }
        public function getThemeCollection():Array{
            return (this.m_themeCollection);
        }
        public function get spawnNpcs():Array{
            return (this.m_spawnNpcs);
        }
        public function get spawnNpcWeights():Array{
            return (this.m_spawnNpcWeights);
        }
        public function get isEmptyLot():Boolean{
            return ((this.className == "LotSite"));
        }
        public function getRandomSpawnNpc():String{
            var _local1:int;
            var _local2:String;
            if (((!((this.m_spawnNpcs == null))) && ((this.m_spawnNpcs.length > 0)))){
                _local1 = MathUtil.randomIndexWeighed(this.m_spawnNpcWeights);
                _local2 = this.m_spawnNpcs[_local1];
                if (_local2 != ""){
                    return (_local2);
                };
            };
            return (null);
        }
        public function get mechanicsXml():XMLList{
            return (xml.mechanics);
        }
        public function getClientDisplayMechanicConfig(_arg1:String):MechanicConfigData{
            var config:* = null;
            var mechXML:* = null;
            var mechType:* = _arg1;
            config = null;
            mechXML = this.mechanicsXml.child("clientDisplayMechanics").child("mechanic").(attribute("type") == mechType)[0];
            if (mechXML){
                config = new MechanicConfigData(mechXML);
            };
            return (config);
        }
        public function getGameEventMechanicConfig(_arg1:String, _arg2:String):MechanicConfigData{
            var config:* = null;
            var mechXML:* = null;
            var mechGameMode:* = _arg1;
            var mechType:* = _arg2;
            config = null;
            mechXML = this.mechanicsXml.child("gameEventMechanics").(attribute("gameMode") == mechGameMode).child("mechanic").(attribute("type") == mechType)[0];
            if (mechXML){
                config = new MechanicConfigData(mechXML);
            };
            return (config);
        }
        public function canCountUpgradeActions():Boolean{
            return (((((this.upgrade) && (this.upgrade.requirements))) && (!((this.upgrade.requirements.getRequirementValue(Requirements.REQUIREMENT_UPGRADE_ACTIONS) == null)))));
        }
        public function getItemKeywords():Array{
            return (this.m_keywords);
        }
        public function itemHasKeyword(_arg1:String):Boolean{
            return ((this.m_keywords.indexOf(_arg1) >= 0));
        }
        public function get placeableOn():String{
            return (this.m_placeableOn);
        }
        public function get canPlaceToFriendHome():String{
            return (this.m_canPlaceToFriendHome);
        }
        public function get expireTime():Number{
            return (this.m_expireTime);
        }
        public function get phases():Array{
            return (this.m_phases);
        }
        public function get isPixelInsideAlphaThresholdOveride():uint{
            return (this.m_isPixelInsideAlphaThresholdOveride);
        }
        public function get showGirders():int{
            return (this.m_showGirders);
        }
        public function get bridge():ItemDefinitionBridge{
            return (this.m_item_bridgeDefn);
        }
        public function get floorMysteryBusiness():String{
            return (this.m_floorMysteryBusiness);
        }
        public function preprocessXML(_arg1:XML):XML{
            var _local3:XML;
            var _local4:XML;
            var _local5:XML;
            var _local6:String;
            var _local7:XMLList;
            var _local8:String;
            var _local9:Array;
            var _local10:String;
            var _local11:XMLList;
            var _local2:String = _arg1.attribute("derivesFrom").toString();
            if (_local2 != ""){
                _local3 = Global.gameSettings.getItemXMLByName(_local2).copy();
                for each (_local4 in _arg1.children()) {
                    _local6 = _local4.name().localName;
                    _local7 = _local3.child(_local6);
                    if (_local7.length() == 0){
                    } else {
                        delete _local3.child(_local6)[0];
                    };
                };
                for each (_local4 in _arg1.children()) {
                    _local3.appendChild(_local4);
                };
                for each (_local5 in _arg1.attributes()) {
                    _local8 = _local5.name().localName;
                    if (((!((_local8 == "name"))) && (!((_local3.attribute(_local8).length() == 0))))){
                        delete _local3.@[_local8];
                    };
                };
                for each (_local5 in _arg1.attributes()) {
                    _local8 = _local5.name().localName;
                    if (((((!((_local8 == "className"))) && (!((_local8 == "type"))))) && (!((_local8 == "code"))))){
                        _local3.@[_local8] = _local5.toString();
                    };
                };
                if (_arg1.attribute("doNotInherit").length() > 0){
                    _local9 = String(_arg1.@doNotInherit).split(",");
                    for each (_local10 in _local9) {
                        _local11 = _local3.child(_local10);
                        if (_local11.length() == 0){
                        } else {
                            delete _local3.child(_local10)[0];
                        };
                    };
                };
                _arg1 = _local3;
                Global.gameSettings.addOrReplaceItemXMLByName(_arg1);
            };
            return (_arg1);
        }

    }
}//package Classes 
